from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from time import sleep

url = r'https://www.baidu.com/'
# 初始化谷歌的浏览器对象
# 1.方式1：默认形参
# driver = webdriver.Chrome()

# 2.方式2：指定 Chrome 浏览器位置：options参数
chrome_location = r'E:\python\chrome\chrome-win\chrome.exe'
options = webdriver.ChromeOptions()
options.binary_location = chrome_location
# driver = webdriver.Chrome(test_cases_webtours=test_cases_webtours)

# 3.方式3：指定 Chromedriver  驱动位置：service参数（注意驱动程序）
driver_location = r'E:\python\Python3.10\chromedriver.exe'
service = Service(driver_location)
driver = webdriver.Chrome(options=options, service=service)

# 打开网页
driver.get(url)
sleep(3)

# 关闭浏览器驱动对象
driver.quit()
